package com.yegs.jltqc.U8ServiceImpl;

import com.yegs.jltqc.U8Service.CgbarcodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CgbarcodeServiceImpl implements CgbarcodeService {

    @Autowired
    @Qualifier("u8JdbcTemplate")
    private JdbcTemplate u8JdbcTemplate;



    @Override
    public List<Map<String, Object>> findAllByAutoId(Long autoid) {
        String sql = "select * from jltsystem.dbo.ymh_cgBarcode where autoid = ? order by cbarcode asc ";
        return u8JdbcTemplate.queryForList(sql,autoid);
    }

    @Override
    public Map<String, Object> findByBarcode(String barcode) {
        String sql = "select * from JLTSystem.dbo.ymh_cgBarcode where cbarcode = ? ";
        List<Map<String, Object>> list = u8JdbcTemplate.queryForList(sql, barcode);
        if(list.size() == 0){
            return null;
        }
        return list.get(0);
    }


}
